package com.service.strategy;

/**
 * 电影票
 * 充当环境对象
 *
 * @author wangyongkun
 * @create 2021/3/24
 */
public class MovieTicket {
    private double price;

    private Discount discount; // 维护一个对抽象折扣类的应用

    public void setPrice(double price) {
        this.price = price;
    }

    // 注入一个折扣对象
    public void setDiscount(Discount discount) {
        this.discount = discount;
    }

    public double getPrice() {
        // 调用折扣类的折扣计算方法
        return discount.calculate(this.price);
    }

}
